﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;

// usar para CODE FIRST pattern
// los puede ponerse en otro arhivo modelParkingValidation.cs, usando partial class
namespace Parking.Models
{
    public class Position
    {
        public int PositionId { get; set; }

        [Required(ErrorMessage = "Por favor digite un número válido")]
        [Display(Name = "#")]
        [StringLength(10, ErrorMessage = "El tamaño {0} máximo es {1} caracteres.", MinimumLength = 1)]
        public string Number { get; set; }
        public string Location { get; set; }

        public virtual ICollection<Parking> Parkings { get; set; }
    }

    public class Parking
    {
        public int ParkingId { get; set; }
        public int PositionId { get; set; }

        [Required(ErrorMessage = "Por favor digite un número de placa válido")]
        [Display(Name = "Vehicle ID")]
        [StringLength(50, ErrorMessage = "El tamaño {0} máximo es {1} caracteres.", MinimumLength = 1)]
        public string VehicleNumber { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime? EndTime { get; set; }
        //[Range(1, 100, ErrorMessage = "Price must be between $1 and $100")]
        [DataType(DataType.Currency)]
        //[DisplayFormat(DataFormatString = "{0:c}")]
        public decimal? Total { get; set; }

        public virtual Position Position { get; set; }
    }    

    public class ParkingContext : DbContext
    {
        public DbSet<Parking> Parkings { get; set; }
        public DbSet<Position> Positions { get; set; }
    }
}